package com.mapproject.industrymap.controller;

import com.mapproject.industrymap.service.JDBCOperationService;
import com.mapproject.industrymap.utils.JDBCOperation;
import com.mapproject.industrymap.utils.ReturnValue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/jdbc")
public class JdbcOperationController {
    @Autowired
    JDBCOperationService jdbcOperationService;
    /**
     * 查询表字段
     * @param tablename（要查询的表名）
     * @return
     */
    @RequestMapping(value = "/gettablecolumn")
    public ReturnValue getTableColumn(@RequestParam(value = "tablename")String tablename){
        return jdbcOperationService.getColumnname(tablename);
    }

    /**
     * 根据表名及字段名称查询字段值
     * @param tablename（要查询的表名）
     * @param columnname（要查询的字段名）
     * @return
     */
    @RequestMapping(value = "/getcolumnvalue")
    public ReturnValue getColumnValue(@RequestParam(value = "tablename")String tablename,@RequestParam(value = "columnname")String columnname){
        return jdbcOperationService.getColumnValue(tablename,columnname);

    }
}
